# 代码所有：cxw
# 开发时间：2021/11/3 16:35

# class Dog():
#     def __init__(self,name,age):
#         self.name=name
#         self.age=age
#     def sit(self):
#         print(self.name.title()+" is now sitting.")
#     def roll(self):
#         print(self.name.title()+" rollow over!")
# mydog=Dog('whill',6)
# print("my dog name is "+mydog.name.title()+".")
# print("my dog "+str(mydog.age)+" year old!")
# mydog.sit()
# mydog.roll()
# yourdog=Dog('creazy',9)
# print("my dog name is "+yourdog.name.title()+".")
# print("my dog "+str(yourdog.age)+" year old!")
# yourdog.sit()

# class Restaur():
#     def __init__(self,restaurant_name,restaurant_type):
#         self.name=restaurant_name
#         self.type=restaurant_type
#     def describe_restaurant(self):
#         print("the res name is ",self.name.title()," and ","the type  is ",self.type.title())
#     def open_restaurant(self):
#         print("we are opening!")
# myrestaur=Restaur('wsyu','haochi')
# myrestaur.describe_restaurant()
# myrestaur.open_restaurant()
# yourestaur=Restaur('pgl','buhaochi')
# yourestaur.describe_restaurant()
# yourestaur.open_restaurant()


# class User:#类
#     def __init__(self,firstname,lastname): #firstname,lastname就是另外三个形参，__init__()接受形参的值
#         self.firstnames=firstname
#         self.lastnames=lastname  #访问属性的值
#         self.uuser=0
#     def describe_user(self):  #方法
#         print("your firstname is ",self.firstnames," lastname is ",self.lastnames," uusser",self.uuser)
#     def greet_user(self):  #方法
#         print("welocme to you !")
#     def update_user(self,change):
#         self.uuser=change
# cxwuser=User("c","xw")  #实例
# #cxwuser.uuser=24
# cxwuser.update_user(24)
# cxwuser.describe_user()
# cxwuser.greet_user()
# xbuser=User("x","b")
# #xbuser.uuser=56
# xbuser.update_user(56)
# xbuser.describe_user()
# xbuser.greet_user()

# class Car():
#     def __init__(self,pinpai,open,year):
#         self.pp=pinpai
#         self.opening=open
#         self.years=year
#         self.out=0
#     def describe(self):
#         print("your car is ",self.pp," open or outback ",str(self.opening),"year is ",self.years,"miles: ",self.out)
#     def update(self,mmm):
#         self.out=mmm
#     def updates(self,ooo):
#         self.out+=ooo
# mycar=Car('dukadi','potback',2016)
# mycar.update(23500)
# mycar.describe()
# mycar.updates(100)
# mycar.describe()

# class Restaur():
#     def __init__(self,restaurant_name,restaurant_type):
#         self.name=restaurant_name
#         self.type=restaurant_type
#         self.num=0
#     def describe_restaurant(self):
#         print("the res name is ",self.name.title()," and ","the type  is ",self.type.title()," have ",self.num,"come here .")
#     def open_restaurant(self):
#         print("we are opening!")
#     def set_restaurant(self,nums):
#         self.num=nums
#     def increment(self,nnums):
#         self.num+=nnums
# myrestaur=Restaur('wsyu','haochi')
# myrestaur.describe_restaurant()
# myrestaur.set_restaurant(100)
# myrestaur.describe_restaurant()
# myrestaur.increment(110)
# myrestaur.describe_restaurant()
# myrestaur.open_restaurant()

# class User():
#     def __init__(self,login_attempts):
#         self.a=login_attempts
#     def increment_users(self):
#         self.a+=1
#     def incres(self):
#         self.a=0
#     def describe(self):
#         print('user ',self.a)
# myuser=User(1)
# myuser.increment_users()
# myuser.describe()
# myuser.increment_users()
# myuser.describe()
# myuser.increment_users()
# myuser.describe()
# myuser.incres()
# myuser.describe()

'''class Car():
    def __init__(self,pinpai,open,year):
        self.pp=pinpai
        self.opening=open
        self.years=year
        self.out=0
    def describe(self):
        print("your car is ",self.pp," open or outback ",self.opening,"year is ",str(self.years),"miles: ",self.out)
    def update(self,mmm):
        self.out=mmm
    def updates(self,ooo):
        self.out+=ooo'''
# mycar=Car('dukadi','potback',2016)
# mycar.update(23500)
# mycar.describe()
# mycar.updates(100)
# mycar.describe()
'''class Elec(Car):
    def __init__(self,pinpai,open,year):  #方法__init__()接受创建Car实例所需的信息，这里要和父类定义的属性相同，不可少也不可以多
        #可用super(Elec, self).__init__(pinpai,open,year#  #super()参数1必须是type，而不是Elec，要调用时 super(Elec, self).__init__(pinpai,open,year)
        super().__init__(pinpai,open,year)
        #super是一个特殊函数，帮助python将父类和子类结合起来，让子类拥有和父类相同的所有属性。父类也称超类（superclass）
        self.battery=50  #但是子类的特有属性只有子类包含，而父类则是不包含的
    def make(self):  #子类自己也可以定义自己的方法
        print(self.pp,self.opening,self.years,self.out)
        print(self.battery)
    def fill(self):
        print("the gas is broken")
mycar_tes=Elec('tes','model',2016)
print(mycar_tes.describe())
print(mycar_tes.make())
print(mycar_tes.fill())'''

# class Car():
#     def __init__(self,pinpai,open,year):
#         self.pp=pinpai
#         self.opening=open
#         self.years=year
#         self.out=0
#     def describe(self):
#         print("your car is ",self.pp," open or outback ",self.opening,"year is ",str(self.years),"miles: ",self.out)
#     def update(self,mmm):
#         self.out=mmm
#     def updates(self,ooo):
#         self.out+=ooo
# class Battery():
#     def __init__(self,battery_size=85):
#         self.battery=battery_size
#     def describe(self):
#         print("this has ",self.battery," battery!")
#     def battery_length(self):
#         if self.battery==70:
#             range=250
#         elif self.battery==85:
#             range=245
#         mm="this car can go on "+str(range)
#         mm+=" miles on a full charge."
#         print(mm)
# class Elec(Car):
#     def __init__(self,pinpai,open,year):
#         super(Elec, self).__init__(pinpai,open,year)
#         self.battery=Battery()  #在Elec类中，添加一个名为battery的属性，自动创建一个属于Battery的实例，且无实参传入,没有继承任何类
# mycar_tes=Elec('tes','model',2016)
# print(mycar_tes.describe())
# mycar_tes.battery.describe()
# mycar_tes.battery.battery_length()

class User():
    def __init__(self,firstname,last_name,**others):
        self.fname=firstname
        self.lname=last_name
    def describe_user(self):
        print("your firstname is ",self.fname," lastname is ",self.lname,)
    def greet_user(self):
        print("hello ",self.fname," ",self.lname)
cxw=User("c","xw")
cxw.describe_user()
cxw.greet_user()
'''class Admin(User):
    def __init__(self,firstname,last_name):
        super(Admin, self).__init__(firstname,last_name)
        self.privileges=["can add","can delete","can ban users"]
    def show_privileges(self):
        print(self.privileges)'''
# cxwu=Admin("x","b")
# cxwu.describe_user()
# cxwu.greet_user()
# cxwu.show_privileges()

class Admin(User):
    def __init__(self,firstname,last_name):
        super(Admin, self).__init__(firstname,last_name)
        self.privileges=Privileges()
class Privileges():
    def __init__(self):
        self.privilege=["can add","can delete","can ban users"]
    def show_users(self):
        print(self.privilege)
xbuser=Admin("s","b")
xbuser.describe_user()
xbuser.greet_user()
xbuser.privileges.show_users()
